/*
 * Rhy View Core Lib
 * 
 * @author Tristan Maindron
 * 
 */

Rhy.view = {
    
    style: {
        get: function (el, attr)
        {
            var x = document.getElementById(el);
            if (x.currentStyle)
                var y = x.currentStyle[attr];
            else if (window.getComputedStyle)
                var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(attr);
            return y;
        },
        
        set: function (el, attr, value){
            el.style[attr] = value;
        },
        
        isVisible: function(o){
            return o.offsetWidth > 0 || o.offsetHeight > 0;
        }
    },
    
	GlobalPositioning: {
        
		getOffsetLeft: function(o){
			var r = 0;

			while(o){
                r += o.offsetLeft;
				o = o.offsetParent;
			}
			return r;
		},
        
		getOffsetTop: function(o){
			var r = 0;

			while(o){
                r += o.offsetTop;
				o = o.offsetParent;
			}
			return r;
		},
        
		getOffsetWidth: function(o){
            return o.offsetWidth;
		},
        
		getOffsetHeight: function(o){
            return o.offsetHeight;
		}
	}
}

Rhy.view.gp = Rhy.view.GlobalPositioning;
